/*
 * filesystem.h
 *
 *  Created on: Oct 18, 2013
 *      Author: Ken Arok
 */

#ifndef FILESYSTEM_H_
#define FILESYSTEM_H_

#include "ff.h"

#define FILESYSTEM_APPEND		0x01
#define FILESYSTEM_OVERWRITE	0x02
#define FILESYSTEM_INSERT		0x04
#define FILESYSTEM_FOWARD		0x08
#define FILESYSTEM_REWIND		0x10

/* File system api function return code*/

typedef enum {
	FS_OK = 0,				/* (0) Succeeded */
	FS_DISK_ERR,			/* (1) A hard error occurred in the low level disk I/O layer */
	FS_INT_ERR,				/* (2) Assertion failed */
	FS_NOT_READY,			/* (3) The physical drive cannot work */
	FS_NO_FILE,				/* (4) Could not find the file */
	FS_NO_PATH,				/* (5) Could not find the path */
	FS_INVALID_NAME,		/* (6) The path name format is invalid */
	FS_DENIED,				/* (7) Access denied due to prohibited access or directory full */
	FS_EXIST,				/* (8) Access denied due to prohibited access */
	FS_INVALID_OBJECT,		/* (9) The file/directory object is invalid */
	FS_WRITE_PROTECTED,		/* (10) The physical drive is write protected */
	FS_INVALID_DRIVE,		/* (11) The logical drive number is invalid */
	FS_NOT_ENABLED,			/* (12) The volume has no work area */
	FS_NO_FILESYSTEM,		/* (13) There is no valid FAT volume */
	FS_MKFS_ABORTED,		/* (14) The f_mkfs() aborted due to any parameter error */
	FS_TIMEOUT,				/* (15) Could not get a grant to access the volume within defined period */
	FS_LOCKED,				/* (16) The operation is rejected according to the file sharing policy */
	FS_NOT_ENOUGH_CORE,		/* (17) LFN working buffer could not be allocated */
	FS_TOO_MANY_OPEN_FILES,	/* (18) Number of open files > _FS_SHARE */
	FS_INVALID_PARAMETER	/* (19) Given parameter is invalid */
} fs_status_t;


fs_status_t vFileSystem_MountDrive(uint8_t _vol);
fs_status_t vFileSystem_UmountDrive(uint8_t _vol);
fs_status_t vFileSystem_ScanFile(const char *_path);
fs_status_t vFileSystem_NewFile(const char *_path);
fs_status_t vFileSystem_NewFolder(const char *_path);
fs_status_t vFileSystem_CreateDirectory(const char *_path);
fs_status_t vFileSystem_OpenFile(FIL *_fp, const char *_path);
fs_status_t vFileSystem_Browse(const char *_path);
fs_status_t vFileSystem_CloseFile(FIL *_fp);
fs_status_t vFileSystem_EditFile(FIL *_fp, const void *_pbuf, uint32_t _ptr_offset, uint8_t _flag);


#endif /* FILESYSTEM_H_ */
